package com.sixmac.controller.api;

import com.sixmac.controller.common.CommonController;
import com.sixmac.core.bean.Result;
import com.sixmac.entity.Area;
import com.sixmac.service.AreasService;
import com.sixmac.utils.JsonUtil;
import com.sixmac.utils.WebUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * Created by Administrator on 2016/3/16 0016.
 */
@Controller
@RequestMapping(value = "api/sort")
public class SortApi extends CommonController {

    @Autowired
    private AreasService areasService;

    /**
     * @api {post} /api/sort/afflatusAreaList 灵感图区域列表
     * @apiName sort.afflatusAreaList
     * @apiGroup sort
     * @apiSuccess {Object} list 灵感图区域列表
     * @apiSuccess {Integer} list.id 区域id
     * @apiSuccess {String} list.name 区域名称
     * @apiSuccess {String} list.updateTime 更新时间
     */
    @RequestMapping(value = "/afflatusAreaList")
    public void afflatusAreaList(HttpServletResponse response) {
        List<Area> list = areasService.findAll();

        Result obj = new Result(true).data(createMap("list", list));
        String result = JsonUtil.obj2ApiJson(obj, "productNum");
        WebUtil.printApi(response, result);
    }
}
